<!DOCTYPE html>
<html lang="zh-Hans">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.3.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/blog/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/blog/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/blog/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/blog/images/logo.svg" color="#222">

<link rel="stylesheet" href="/blog/css/main.css">

<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&display=swap&subset=latin,latin-ext">
<link rel="stylesheet" href="/blog/lib/font-awesome/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    hostname: new URL('https://guodh.gitee.io/blog').hostname,
    root: '/blog/',
    scheme: 'Pisces',
    version: '7.7.1',
    exturl: false,
    sidebar: {"position":"left","display":"post","padding":18,"offset":12,"onmobile":false},
    copycode: {"enable":true,"show_result":true,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    comments: {"style":"tabs","active":null,"storage":true,"lazyload":false,"nav":null},
    algolia: {
      appID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}}
  };
</script>

  <meta name="description" content="平时都是关注与业务的扩展，然后现在发现还是需要关注技术的扩展。无论是现在在做的退款助手还是Data项目，都是依赖于定时任务的调度。当用户数一旦大于某个基数，对于分布式调度来说还是很有问题的。">
<meta property="og:type" content="article">
<meta property="og:title" content="分布式调度中心选型">
<meta property="og:url" content="https://guodh.gitee.io/blog/2019/03/27/2019/%E5%88%86%E5%B8%83%E5%BC%8F%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%E9%80%89%E5%9E%8B/index.html">
<meta property="og:site_name" content="蛋蛋的小屋">
<meta property="og:description" content="平时都是关注与业务的扩展，然后现在发现还是需要关注技术的扩展。无论是现在在做的退款助手还是Data项目，都是依赖于定时任务的调度。当用户数一旦大于某个基数，对于分布式调度来说还是很有问题的。">
<meta property="og:locale">
<meta property="article:published_time" content="2019-03-27T07:03:21.000Z">
<meta property="article:modified_time" content="2019-03-30T08:33:04.000Z">
<meta property="article:author" content="RunningEgg">
<meta property="article:tag" content="技术">
<meta name="twitter:card" content="summary">

<link rel="canonical" href="https://guodh.gitee.io/blog/2019/03/27/2019/%E5%88%86%E5%B8%83%E5%BC%8F%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%E9%80%89%E5%9E%8B/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true
  };
</script>

  <title>分布式调度中心选型 | 蛋蛋的小屋</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/blog/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">蛋蛋的小屋</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
        <p class="site-subtitle">来了就看看吧，没有刀剑只有故事</p>
  </div>

  <div class="site-nav-toggle">
    <div class="toggle" aria-label="Toggle navigation bar">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
        <li class="menu-item menu-item-home">

    <a href="/blog/" rel="section"><i class="fa fa-fw fa-home"></i>Home</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/blog/about/" rel="section"><i class="fa fa-fw fa-user"></i>About</a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/blog/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>Archives</a>

  </li>
        <li class="menu-item menu-item-book">

    <a href="/blog/book/" rel="section"><i class="fa fa-fw fa-archive"></i>book</a>

  </li>
  </ul>

</nav>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content">
            

  <div class="posts-expand">
      
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block " lang="zh-Hans">
    <link itemprop="mainEntityOfPage" href="https://guodh.gitee.io/blog/2019/03/27/2019/%E5%88%86%E5%B8%83%E5%BC%8F%E8%B0%83%E5%BA%A6%E4%B8%AD%E5%BF%83%E9%80%89%E5%9E%8B/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/blog/images/avatar.gif">
      <meta itemprop="name" content="RunningEgg">
      <meta itemprop="description" content="写下我的点点滴滴，写下我对这个世界的看法，还有我内心锁崇拜的技术">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="蛋蛋的小屋">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          分布式调度中心选型
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">Posted on</span>

              <time title="Created: 2019-03-27 15:03:21" itemprop="dateCreated datePublished" datetime="2019-03-27T15:03:21+08:00">2019-03-27</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">Edited on</span>
                <time title="Modified: 2019-03-30 16:33:04" itemprop="dateModified" datetime="2019-03-30T16:33:04+08:00">2019-03-30</time>
              </span>

          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>平时都是关注与业务的扩展，然后现在发现还是需要关注技术的扩展。无论是现在在做的退款助手还是Data项目，都是依赖于定时任务的调度。当用户数一旦大于某个基数，对于分布式调度来说还是很有问题的。</p>
<a id="more"></a>

<p>看来在对比一个系统的时候，还是使用对比来比较好的认清它的优缺点。</p>
<h2 id="xxl-job"><a href="#xxl-job" class="headerlink" title="xxl-job"></a>xxl-job</h2><p>关于xxl-job，定位于一款简单的分布式调度框架，采用了Master-Slave的架构，自研RPC进行短连接维持Master和Slave的状态，提供丰富的Master调度任务，可以手动触发任务、终止任务，提供DAG调用、Slave故障任务转移。</p>
<p>对于Slave支持较弱，但是提供了日志上报以及线程池隔离等功能。</p>
<p>由于是Master-Slave结构，能够比较好的支持多语言结构</p>
<h3 id="我认为的缺点："><a href="#我认为的缺点：" class="headerlink" title="我认为的缺点："></a>我认为的缺点：</h3><ol>
<li>缺少宿主机的性能监控，CPU，JVM。无法通过性能来分布式的发布任务。</li>
<li>大批量任务失败的处理</li>
<li>slave 是无状态的，缺少slave的任务状态监控</li>
<li>大批量Master下发任务的时候会出现问题</li>
</ol>
<h2 id="elastic-job-lite"><a href="#elastic-job-lite" class="headerlink" title="elastic-job-lite"></a>elastic-job-lite</h2><p>定位于轻量级无中心化解决方案，使用Jar包的形式来提供分布式任务的协调服务。依赖于Zookeeper的机制来进行心跳，手动触发任务等功能。</p>
<p>每个节点都是执行节点，会将执行信息同步到本地放置在Map&lt;String, JobName&gt;中，主节点的作用仅仅是有新加入的节点，对于Job进行重新分配。对于新加入节点，仅仅会在每个节点同步不一个状态“重新分片标记”，当下一次跑任务的时候，会进行分片的处理。</p>
<p>代码优秀，扩展性很强。而且作者在一开始就已经设想好了要支持Docker + Mesos的扩展机制，很多方法都通过门面模式将底层实现给遮蔽起来。</p>
<h3 id="我认为的缺点：-1"><a href="#我认为的缺点：-1" class="headerlink" title="我认为的缺点："></a>我认为的缺点：</h3><ol>
<li>控制台触发机制比较鸡肋，还有很多调度的策略需要支持</li>
<li>同样缺少性能的监控，CPU，JVM等，都将影响任务的执行</li>
</ol>
<h2 id="结构上不同"><a href="#结构上不同" class="headerlink" title="结构上不同"></a>结构上不同</h2><p>|  | xxl-job | elastic-job |<br>| — | — |<br>| 结构 | 中心化 Master-Slave | 无中心化（有主节点，但是仅仅处理分片策略以及日志） |</p>
<h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>xxl-job更多维护的是Master的状态，考虑更多的是调度，以及统计等。而elastic-job恰恰相反，关注的是Slave，同时能加信息同步到Master一份。用户需要考虑，在实际使用场景中，Master会不会成为瓶颈，典型的就是RPC调用过多，Master需要处理很多的RPC请求。</p>
<h2 id="关于Mesos以及K8S"><a href="#关于Mesos以及K8S" class="headerlink" title="关于Mesos以及K8S"></a>关于Mesos以及K8S</h2><p>当开发更多的关注于性能以及能效的时候，如何动态的扩容会将是一个很好的话题。</p>

    </div>

    
    
    

      <footer class="post-footer">
          <div class="post-tags">
              <a href="/blog/tags/%E6%8A%80%E6%9C%AF/" rel="tag"># 技术</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/blog/2019/03/24/2019/Java%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/" rel="prev" title="Java基础知识">
      <i class="fa fa-chevron-left"></i> Java基础知识
    </a></div>
      <div class="post-nav-item">
    <a href="/blog/2019/04/26/2019/Dubbo%E7%9A%84protocol/" rel="next" title="Dubbo的protocol">
      Dubbo的protocol <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  

  </div>


          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let activeClass = CONFIG.comments.activeClass;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          Table of Contents
        </li>
        <li class="sidebar-nav-overview">
          Overview
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#xxl-job"><span class="nav-number">1.</span> <span class="nav-text">xxl-job</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%88%91%E8%AE%A4%E4%B8%BA%E7%9A%84%E7%BC%BA%E7%82%B9%EF%BC%9A"><span class="nav-number">1.1.</span> <span class="nav-text">我认为的缺点：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#elastic-job-lite"><span class="nav-number">2.</span> <span class="nav-text">elastic-job-lite</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#%E6%88%91%E8%AE%A4%E4%B8%BA%E7%9A%84%E7%BC%BA%E7%82%B9%EF%BC%9A-1"><span class="nav-number">2.1.</span> <span class="nav-text">我认为的缺点：</span></a></li></ol></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E7%BB%93%E6%9E%84%E4%B8%8A%E4%B8%8D%E5%90%8C"><span class="nav-number">3.</span> <span class="nav-text">结构上不同</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E6%80%BB%E7%BB%93"><span class="nav-number">4.</span> <span class="nav-text">总结</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%85%B3%E4%BA%8EMesos%E4%BB%A5%E5%8F%8AK8S"><span class="nav-number">5.</span> <span class="nav-text">关于Mesos以及K8S</span></a></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
  <p class="site-author-name" itemprop="name">RunningEgg</p>
  <div class="site-description" itemprop="description">写下我的点点滴滴，写下我对这个世界的看法，还有我内心锁崇拜的技术</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/blog/archives/">
        
          <span class="site-state-item-count">89</span>
          <span class="site-state-item-name">posts</span>
        </a>
      </div>
      <div class="site-state-item site-state-tags">
        <span class="site-state-item-count">24</span>
        <span class="site-state-item-name">tags</span>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="mailto:guodh_1@163.com" title="E-Mail → mailto:guodh_1@163.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">RunningEgg</span>
</div>
  <div class="powered-by">Powered by <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> v5.3.0
  </div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">Theme – <a href="https://pisces.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.7.1
  </div>

        








      </div>
    </footer>
  </div>

  
  <script src="/blog/lib/anime.min.js"></script>
  <script src="/blog/lib/velocity/velocity.min.js"></script>
  <script src="/blog/lib/velocity/velocity.ui.min.js"></script>

<script src="/blog/js/utils.js"></script>

<script src="/blog/js/motion.js"></script>


<script src="/blog/js/schemes/pisces.js"></script>


<script src="/blog/js/next-boot.js"></script>




  















  

  

</body>
</html>
